<template>
	<view class="g-work f-bc-whilte">
		<u-tab :tabIndex="currentIndex" :tabArr="tabArr" :customStyle="`padding: 0 136rpx;`" @change="changeHandler"></u-tab>
		<pulldown-refresh ref="mixPulldownRefresh" :top="88" :backColor="'#f8f8f8'" @refresh="onPulldownReresh" @setEnableScroll="setEnableScroll">
			<swiper :current="currentIndex" :indicator-dots="false" :autoplay="false" :duration="500" class="g-list" @change="changeHandler">
				<swiper-item v-for="item in tabList" :key="item.key">
					<scroll-view scroll-y="true" class="g-list" @scrolltolower="toLowerHandler">
						<work-item v-for="i in item.list" :key="i.id"></work-item>
						<loadmore :visible="true" :status="item.loadStatus"></loadmore>
					</scroll-view>
				</swiper-item>
			</swiper>
		</pulldown-refresh>
	</view>
</template>

<script>
import tabList from '../../mixins/tabList.js';
export default {
	mixins: [tabList],
	data() {
		return {
			tabArr: ['待办', '已办'],
			currentIndex: 0
		};
	},
	methods: {
		getList() {},
		//设置scroll-view是否允许滚动，在小程序里下拉刷新时避免列表可以滑动
		setEnableScroll(enable) {
			if (this.enableScroll !== enable) {
				this.enableScroll = enable;
			}
		},
		// 停止
		stopPullRefresh() {
			const that = this;
			setTimeout(() => {
				that.$refs.mixPulldownRefresh && that.$refs.mixPulldownRefresh.endPulldownRefresh();
			}, 500);
		},
		/**
		 * 下拉加载
		 * */
		onPulldownReresh() {
			const that = this;
			if (that.isLogin) {
				let listObj = that.tabList[that.tabIndex];
				listObj.page = 1;
				that.getList();
			} else {
				that.stopPullRefresh();
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.g-work {
	.g-list {
		background-color: #f5f5f5;
		height: calc(100vh - 88rpx);
	}
}
</style>
